package com.example.modules.scquartz.listenner;

import com.example.modules.scquartz.domain.TaskDO;
import com.example.modules.scquartz.service.JobService;
import com.example.modules.scquartz.config.QuartzManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(value = 1)
public class ScheduleJobInitListener implements CommandLineRunner {

	@Autowired
	JobService scheduleJobService;

	@Autowired
	QuartzManager quartzManager;

	@Override
	public void run(String... arg0) throws Exception {
		try {
//			scheduleJobService.initSchedule();
			TaskDO taskDO = new TaskDO();
			//开启
			taskDO.setJobStatus("1");
			taskDO.setBeanClass("com.example.modules.scquartz.job.ChickenJob");
			taskDO.setCronExpression("0/1 * * * * ?");
			taskDO.setJobGroup("test");
			taskDO.setDescription("测试任务");
			taskDO.setJobName("test01");
			scheduleJobService.test(taskDO);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}